package com.neusoft.elmboot.mapper;

import com.neusoft.elmboot.po.Orders;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 订单
 * Mapper
 * （xml文件位于resources.mapper）
 */

@Mapper
public interface OrdersMapper {

    @Insert("insert into orders values(null,#{userId},#{businessId},#{orderDate},#{orderTotal},#{daId},#{orderState},#{type},#{envelopeId},#{delTag})")
    @Options(useGeneratedKeys = true,keyProperty = "orderId",keyColumn = "orderId")
    public int saveOrders(Orders orders);
    public Orders getOrdersById(Integer ordersId);
    public List<Orders> listOrdersByUserId(String userId);

    @Update("update orders set orderState = 1 where orderId=#{orderId}")
    void updateOrderState(Integer orderId);

    @Update("update orders set delTag=1 where orderId=#{orderId}")
    void deleteOrder(Orders orders);

    @Update("update orders set delTag=1 where orderState=0")
    void deleteAllOrderNoPay();
}
